﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


using System.ComponentModel;
using System.Runtime.CompilerServices;
using Prism.Regions;
using System.Globalization;

namespace TLDNs.Views
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : HandyControl.Controls.Window
    {
        public MainWindow(IRegionManager regionManager)
        {
            InitializeComponent();
            regionManager.RegisterViewWithRegion("SystemInfoRegion", typeof(SystemInfo));
            regionManager.RegisterViewWithRegion("ParameterEditRegion", typeof(ParameterEdit));
            regionManager.RegisterViewWithRegion("ParameterExportRegion", typeof(ParameterExport));
            regionManager.RegisterViewWithRegion("ErrorHistoryRegion", typeof(ErrorHistory));
            regionManager.RegisterViewWithRegion("AppUpdateRegion", typeof(AppUpdate));
            regionManager.RegisterViewWithRegion("ParameterMonitoringRegion", typeof(ParameterMonitoring));
            regionManager.RegisterViewWithRegion("SystemInfoGraphRegion", typeof(SystemInfoGraph));
            regionManager.RegisterViewWithRegion("TestFunctionsRegion", typeof(TestFunctions));
            regionManager.RegisterViewWithRegion("ParameterEditTreeRegion", typeof(ParameterEditTree));

            Rect restoreBounds = Properties.Settings.Default.MainRestoreBounds;
            this.WindowState = WindowState.Normal;
            this.Left = restoreBounds.Left;
            this.Top = restoreBounds.Top;
            this.Width = restoreBounds.Width;
            this.Height = restoreBounds.Height;
            //设置窗口状态
            this.WindowState = Properties.Settings.Default.MianWinStatus;
            ((App)Application.Current).UpdateSkin(Properties.Settings.Default.UISkinType);

        }
    }

    [ValueConversion(typeof(bool), typeof(GridLength))]
    public class BoolToGridLengthConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            GridLength num = new GridLength();
            bool val = (bool)value;
            if (val)
            {
                num = new GridLength(120);
            }
            else
            {
                num = new GridLength(45);
            }
            return num;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            GridLength val = (GridLength)value;

            if (val.Value >= 120)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }


    public class Student
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
    }

}
